/*
 * @Description:
 * @FilePath: /stm32f1_library/USER/bsp/tim.h
 * @Author: Wei Zhou
 * @Github: https://github.com/zromyk
 * @Date: 2021-04-28 15:25:19
 * @LastEditors: Wei Zhou
 * @LastEditTime: 2021-09-05 13:14:38
 * @Copyright: Copyright ? 2017 muyiro. All rights reserved.
 */

#ifndef TIM_INIT_H
#define TIM_INIT_H

#include "my_include.h"

typedef struct
{
    TIM_TypeDef*    TIMx;
    uint32_t        RCC_Periph_TIM;
    IRQn_Type       TIMx_IRQn;
} TIM_Dev;

/* Exported variable ---------------------------------------------------------*/

extern TIM_Dev tim7;

/* initialize functions ----------------------------------------------------- */

/**
 * @brief  初始化定时器
 * @param  *tim:        point to a TIM_Dev.
 * @param  us:          定时时间，单位为 us
 * @param  priority:    主优先级
 * @param  subPriority: 子优先级
 * @retval None
 */
void tim_us_init(TIM_Dev *tim, uint16_t us, uint8_t priority, uint8_t subPriority);

/**
 * @brief  初始化定时器
 * @param  *tim:        point to a TIM_Dev.
 * @param  ms:          定时时间，单位为 ms
 * @param  priority:    主优先级
 * @param  subPriority: 子优先级
 * @retval None
 */
void tim_ms_init(TIM_Dev *tim, uint16_t ms, uint8_t priority, uint8_t subPriority);

#endif /* TIM_INIT_H */
